package com.xiaozhaovip.demo.intf.mapper;

import com.xiaozhaovip.demo.intf.entity.YueQiLaiActivityCollect;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 活动收藏 持久层
 *
 * @author Cauli
 */
@Mapper
public interface YueQiLaiActivityCollectMapper {
    @Insert("insert into yue_activity_collect (UserId, ActivityId, Status, AddTime, UpdateTime) VALUES (#{userId}, #{activityId}, #{status}, now(), now())")
    int insert(YueQiLaiActivityCollect yueQiLaiActivityCollect);

    @Select("select id, UserId, ActivityId, `Status`, AddTime, UpdateTime from yue_activity_collect where UserId = #{userId} and ActivityId = #{activityId}")
    YueQiLaiActivityCollect loadByUserIdAndActivityId(int userId, int activityId);

    @Update("update yue_activity_collect set `Status` = #{status}, UpdateTime = now() where id = #{id}")
    int update(YueQiLaiActivityCollect yueQiLaiActivityCollect);

    @Update("update yue_activity_collect set `Status` = #{status}, UpdateTime = now() where UserId = #{userId} and ActivityId = #{activityId}")
    int updateStatusById(int userId, int activityId, int status);
}
